<template>
  <div id="d">
    <van-nav-bar
      title="地址信息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-address-edit
      :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

  <script>
import areaList from "../assets/area.js";
import { Toast } from "vant";


export default {
  name: "Address",
  data() {
    return {
      areaList,
      searchResult: [],
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    onSave() {
      this.$router.push("/Buy");
    },
    onDelete() {
      Toast("delete");
      this.$router.push("/Buy");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "西安钟楼",
            address: "西安市碑林区",
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
  },
};
</script>

  <style scoped>
</style>